/* 页面通用样式 */
@use "../base/variables" as *;
@use "../base/mixins" as *;
@use "sass:color";

/* ===== 页面容器样式 ===== */
.page-container {
  @include theme-transition;
  background: var(--color-bg-tertiary);
  min-height: 100vh;
  padding: var(--spacing-lg);
}

.page-content {
  @include theme-transition;
  background: var(--color-bg-primary);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-base);
  border: 1px solid var(--color-border-secondary);
}

/* ===== 页面标题样式 ===== */
.page-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 8px 0;
  @include theme-transition;
}

.page-subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin: 0;
  @include theme-transition;
}

/* ===== 统计卡片样式 ===== */
.header-stats {
  @include flex-center;
  gap: var(--spacing-lg);
  flex-wrap: wrap;

  .stat-card {
    @include theme-card-hover;
    @include flex-center;
    flex-direction: column;
    padding: var(--spacing-md) var(--spacing-lg);
    min-width: 100px;

    .stat-number {
      font-size: var(--font-size-xl);
      font-weight: var(--font-weight-bold);
      color: var(--color-primary);
      line-height: 1;
      margin-bottom: var(--spacing-xs);
    }

    .stat-label {
      font-size: var(--font-size-sm);
      color: var(--color-text-secondary);
      font-weight: var(--font-weight-medium);
      text-align: center;
    }
  }
}

/* ===== 视图控制样式 ===== */
.view-controls {
  @include flex-between;
  @include theme-toolbar;
  align-items: center;
  margin-bottom: $spacing-xl;

  .view-toggle {
    .el-button-group {
      .el-button {
        @include flex-center;
        gap: $spacing-xs;
        font-weight: $font-weight-medium;
        border-radius: $border-radius-base;
        transition: all $transition-fast;

        &:hover {
          transform: translateY(-1px);
        }
      }
    }
  }

  .view-options {
    @include flex-center;
    gap: $spacing-md;

    .sort-select {
      min-width: 150px;
    }
  }
}

/* ===== 内容区域样式 ===== */
.content-area {
  margin-bottom: $spacing-xl;

  /* 卡片网格布局 */
  &.card-view {
    .problems-grid {
      @include grid-auto-fill(350px, $spacing-lg);
      margin-bottom: $spacing-xl;
    }
  }

  /* 表格布局 */
  &.table-view {
    .table-container {
      @include theme-card;
      overflow: hidden;
    }
  }

  /* 加载状态 */
  &.loading {
    .skeleton-grid {
      @include grid-auto-fill(350px, $spacing-lg);
    }
  }
}

/* ===== 分页器样式 ===== */
.pagination-wrapper {
  @include flex-center;
  @include theme-toolbar;
  padding: $spacing-xl 0;
  margin-top: $spacing-xl;
}

/* ===== 响应式设计 ===== */
@include respond-below(lg) {
  .header-stats {
    gap: $spacing-md;

    .stat-card {
      padding: $spacing-sm $spacing-md;
      min-width: 80px;

      .stat-number {
        font-size: $font-size-lg;
      }

      .stat-label {
        font-size: $font-size-xs;
      }
    }
  }

  .view-controls {
    flex-direction: column;
    gap: $spacing-md;
    align-items: stretch;

    .view-toggle {
      @include flex-center;
    }

    .view-options {
      @include flex-center;
      flex-wrap: wrap;
    }
  }

  .content-area {
    &.card-view {
      .problems-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: $spacing-md;
      }
    }

    &.loading {
      .skeleton-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: $spacing-md;
      }
    }
  }
}

@include respond-below(md) {
  .header-stats {
    gap: $spacing-sm;

    .stat-card {
      padding: $spacing-xs $spacing-sm;
      min-width: 70px;

      .stat-number {
        font-size: $font-size-base;
      }

      .stat-label {
        font-size: $font-size-xs;
      }
    }
  }

  .view-controls {
    padding: $spacing-md;

    .view-toggle {
      .el-button-group {
        width: 100%;

        .el-button {
          flex: 1;
        }
      }
    }
  }

  .content-area {
    &.card-view {
      .problems-grid {
        grid-template-columns: 1fr;
        gap: $spacing-sm;
      }
    }

    &.loading {
      .skeleton-grid {
        grid-template-columns: 1fr;
        gap: $spacing-sm;
      }
    }
  }

  .pagination-wrapper {
    padding: $spacing-md 0;

    .el-pagination {
      .el-pagination__sizes,
      .el-pagination__jump {
        display: none;
      }
    }
  }
}

/* ===== 页面动画效果 ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.content-area {
  animation: fadeInUp 0.6s ease-out;
}

.stat-card {
  animation: fadeInUp 0.6s ease-out;
  animation-fill-mode: both;

  &:nth-child(1) {
    animation-delay: 0.1s;
  }

  &:nth-child(2) {
    animation-delay: 0.2s;
  }

  &:nth-child(3) {
    animation-delay: 0.3s;
  }

  &:nth-child(4) {
    animation-delay: 0.4s;
  }
}

/* ===== 响应式设计（移动端优先） ===== */
@media (max-width: 768px) {
  .page-title {
    font-size: 20px;
  }
}

/* ===== 管理页面通用样式 ===== */

/* 管理页面容器 */
.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: $spacing-lg;
  background: var(--color-bg-tertiary);
  min-height: 100vh;
}

/* 管理页面头部 */
.admin-header {
  @include theme-content-area;
  margin-bottom: $spacing-lg;
  color: var(--color-text-primary);

  .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;

    .title-section {
      .main-title {
        font-size: $font-size-3xl;
        font-weight: $font-weight-bold;
        margin: 0 0 $spacing-sm 0;
        color: $color-text-primary;
      }

      .subtitle {
        font-size: $font-size-base;
        color: $color-text-secondary;
        margin: 0;
        opacity: 0.9;
      }
    }

    .stats-section {
      display: flex;
      gap: $spacing-xl;

      .stat-item {
        text-align: center;

        .stat-value {
          font-size: $font-size-3xl;
          font-weight: $font-weight-bold;
          margin-bottom: $spacing-xs;
          color: $color-text-primary;

          &.active {
            color: $color-success;
          }

          &.joined {
            color: $color-primary;
          }

          &.archived {
            color: $color-text-tertiary;
          }
        }

        .stat-label {
          font-size: $font-size-sm;
          color: $color-text-secondary;
        }
      }
    }
  }

  @include respond-below(md) {
    padding: $spacing-lg;

    .header-content {
      flex-direction: column;
      gap: $spacing-lg;
      text-align: center;

      .title-section {
        .main-title {
          font-size: $font-size-2xl;
        }
      }

      .stats-section {
        gap: $spacing-md;
      }
    }
  }
}

/* 管理页面筛选工具栏 */
.admin-toolbar,
.filter-toolbar {
  @include theme-toolbar;
  margin-bottom: $spacing-lg;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: $spacing-md;

  .toolbar-left {
    display: flex;
    gap: $spacing-md;
    align-items: center;
    flex: 1;

    .search-input {
      width: 300px;
      max-width: 100%;
    }

    .filter-select {
      width: 140px;
      min-width: 120px;
    }
  }

  .toolbar-right {
    display: flex;
    gap: $spacing-md;
    align-items: center;
  }

  @include respond-below(md) {
    flex-direction: column;
    align-items: stretch;

    .toolbar-left {
      flex-wrap: wrap;
      width: 100%;

      .search-input,
      .filter-select {
        width: 100%;
      }
    }

    .toolbar-right {
      width: 100%;

      .el-button {
        width: 100%;
        justify-content: center;
      }
    }
  }
}

/* 管理页面内容区域 */
.admin-content {
  @include theme-content-area;
  overflow: hidden;
  padding: 0;

  .admin-table {

    /* 表格行悬停效果 */
    :deep(.el-table__row) {
      cursor: pointer;
      transition: background-color $transition-fast;

      &:hover {
        background-color: $bg-color-hover !important;
      }
    }

    /* 表格单元格样式 */
    .table-title-cell {
      .title-text {
        font-weight: $font-weight-semibold;
        color: $color-text-primary;
        margin-bottom: $spacing-xs;
        display: block;
        line-height: $line-height-normal;
      }

      .description-text {
        font-size: $font-size-xs;
        color: $color-text-tertiary;
        line-height: $line-height-relaxed;
      }
    }
  }
}

/* 操作按钮组 */
.operation-buttons {
  display: flex;
  gap: $spacing-sm;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;

  .operation-button {
    font-size: $font-size-sm;
    padding: $spacing-xs $spacing-sm;
    font-weight: $font-weight-medium;
    transition: all $transition-fast;

    &:hover {
      transform: translateY(-1px);
    }

    &.el-button--primary {
      &.is-link {
        color: $color-primary;

        &:hover {
          color: $color-primary-dark-1;
        }
      }
    }

    &.el-button--success {
      &.is-link {
        color: $color-success;

        &:hover {
          color: color.adjust($color-success, $lightness: -10%);
        }
      }
    }

    &.el-button--warning {
      &.is-link {
        color: $color-warning;

        &:hover {
          color: color.adjust($color-warning, $lightness: -10%);
        }
      }
    }

    &.el-button--danger {
      &.is-link {
        color: $color-danger;

        &:hover {
          color: color.adjust($color-danger, $lightness: -10%);
        }
      }
    }
  }
}

/* 管理页面分页 */
.admin-pagination {
  @include theme-toolbar;
  display: flex;
  justify-content: center;
  margin-top: $spacing-lg;
  border-top: none;

  @include respond-below(md) {
    padding: $spacing-md;

    :deep(.el-pagination) {

      .el-pagination__sizes,
      .el-pagination__jump {
        display: none;
      }
    }
  }
}